import Main from '@/components/main'
const Component = {
  'menu_table_page': () => import('@/view/menu-page'),
  'role_table_page': () => import('@/view/role-page'),
  'user_table_page': () => import('@/view/user-page'),
  'send_data_order': () => import('@/view/data-order'),
  'option_person_manage': () => import('@/view/option-manage'),
  'waiting_telent/:id': () => import('@/view/waiting-telent'),
  'waiting_paper/:id': () => import('@/view/waiting-paper'),
  'waiting_org/:id': () => import('@/view/waiting-org'),
  'waiting_send_order/:id': () => import('@/view/send-order'),
  '404': () => import('@/view/error-page/404.vue'),
  'domain_keywords': () => import('@/view/domainkeys-page'),
  'keywords': () => import('@/view/keywords-page'),
  //2020.12.17新增可视化
  'visualize': () => import('@/view/visualize'),
}

export function menuFormat (array) {
  var temp = []
  for (var i = 0; i < array.length; i++) {
    if (array[i].type == 1) {
      continue
    }
    let newobj = {
      path: (array[i].level == 1 ? '/' : '') + array[i].url,
      name: array[i].url,
      meta: {
        icon: array[i].icon,
        title: array[i].name,
        hideInMenu: array[i].hide_in_menu != 0,
        notCache: array[i].not_cache != 0,
        hideInBread: array[i].hide_in_bread != 0
      }
    }
    if (array[i].level == 1) {
      newobj['component'] = Main
    } else {
      if (Component[array[i].url]) {
        newobj['component'] = Component[array[i].url]
      } else {
        newobj['component'] = Component['404']
      }
    }
    if (array[i].lists && array[i].lists.length > 0) {
      newobj['children'] = menuFormat(array[i].lists)
    }
    temp.push(newobj)
  }
  // console.log(temp)
  return temp
}
